package level4.gc
{
	import flash.net.LocalConnection;
	import flash.net.SharedObject;
	import flash.system.Security;
	import flash.system.SecurityPanel;
	import flash.system.System;
	import flash.utils.clearTimeout;
	import flash.utils.setInterval;

	public class GC
	{
		public function GC()
		{
		}
		/**
		 * LocalConnection方式,进行回收
		 * 推荐
		 * */
		public static function LC(isTrace:Boolean=false):void{
			try{
				new LocalConnection().connect("foo");
				new LocalConnection().connect("foo");
			}catch(e:*){
				if(isTrace)
					trace(System.totalMemory);
			}
		}
		/**
		 * SharedObject 方式,进行回收
		 * */
		public static function SO(isTrace:Boolean=false):void{
			var num:int = 2;
			var timerId:int = setInterval(function():void{
				if(num-- <= 0){
					clearTimeout(timerId);
					if(isTrace){
						trace(System.totalMemory);
					}
					return;
				}
				SharedObject.getLocal("foo","/");
			},100);
		}
		/**
		 * 弹 设置面板来,进行回收
		 * */
		public static function SP():void{
			Security.showSettings(SecurityPanel.DEFAULT);
			Security.showSettings(SecurityPanel.DEFAULT);
		}
	}
}